package com.sunbeam.catering.user.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.sunbeam.common.utils.DBUtils;

/**
 * @Title: UserInfoDao.java
 * @Package com.sunbeam.catering.user.dao
 * @Description: TODO
 * @author lyz lyzpoq_gmail_com
 * @date 2013/10/17 10:54:38
 * @version V1.0
 */
public class UserInfoDao {

	 private Connection connection = null;
	  private PreparedStatement ps = null; 
	  public UserInfoDao() {
		  DBUtils.getUrlParams();
		  connection=DBUtils.getConnection();
	  }
	  
	/**
	 * @Title: main
	 * @Description: TODO
	 * @param @param args
	 * @return void
	 * @throws
	 */

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	/**
	 * 
	 * @Title: isPersonCanLogin
	 * @Description: TODO
	 * @param @param username
	 * @param @param password
	 * @param @return
	 * @return boolean
	 * @throws
	 */
	public int isPersonCanLogin(String username, String password) {
		 int loginFlg=0;
		    try {
		      ps = connection.prepareStatement("select * from tb_person where name=?");
		      ps.setString(1, username);
		      ResultSet rs = ps.executeQuery();
		      if(rs.next()){
		    	  loginFlg=1;
		      }
		    }
		    catch (SQLException ex) {
		    }
		    return loginFlg;
	}
}

